﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace MushroomPicker
{
    public partial class Help : PhoneApplicationPage
    {
        public Help()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(Help_Loaded);
        }

        void Help_Loaded(object sender, RoutedEventArgs e)
        {
            this.Loaded -= Help_Loaded;
            for (int i = 0; i < shows.Children.Count -1; i++)
            {
                (shows.Children[i] as Mushroom).NextMushroom = shows.Children[i + 1] as Mushroom;
            }
            //(shows.Children[shows.Children.Count - 1] as Mushroom).NextMushroom = shows.Children[0] as Mushroom;
            (shows.Children[shows.Children.Count - 1] as Mushroom).AllShowed = AllShowed;
            (shows.Children[shows.Children.Count - 1] as Mushroom).AllHided = AllHided;
            AllHided();
        }
        private void AllShowed()
        {

            (shows.Children[0] as Mushroom).MushroomState = MushroomState.Hide;
        }
        private void AllHided()
        {
            foreach (var item in shows.Children)
            {
                item.Visibility = System.Windows.Visibility.Collapsed;
            }
            (shows.Children[0] as Mushroom).MushroomState = MushroomState.Showing;
        }
        private void Back_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            this.NavigationService.GoBack();
        }
        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            Sound.PlayExit();
            base.OnNavigatedFrom(e);
        }
    }
}
